package com.example.test.common;

public final class ServiceException extends RuntimeException {

  /**
   * 错误码
   */
  private final Integer code;

  public ServiceException(ServiceExceptionEnum serviceExceptionEnum) {
    // 使用父类的 msg 字段
    super(serviceExceptionEnum.getMsg());
    // 设置错误码
    this.code = serviceExceptionEnum.getCode();
  }

  public Integer getCode() {
    return code;
  }

}
